import { configureStore } from '@reduxjs/toolkit'
import { StateSchema } from '../schemas/common.ts'
import user from './slices/user';
import pub from './slices/pub';
import project from "./slices/project";
import datasource from "./slices/datasource";
import ai from "./slices/ai";

const store = configureStore<StateSchema>({
  reducer: {
    // 将 reducers 添加到 store
    user,
    pub,
    project,
    datasource,
    ai
  },
})

// Infer the `RootState` and `AppDispatch` types from the store itself
export type RootState = ReturnType<typeof store.getState>
// Inferred type: { user: User, status: Status }
export type AppDispatch = typeof store.dispatch

// 导出 store 供 Provider 使用
export default store;